home *** CD-ROM | disk | FTP | other *** search
/ Explorers of the New World / Explorers of the New World.iso / pc / exdata.dir / 00721_DB SCROLL.ls < prev    next >
Encoding:
Text File  |  1995-09-10  |  3.7 KB  |  102 lines

  1. on scrollArea clickV, scrollSprite, scrollField
  2.   if scrollField = "browser" then
  3.     clearDatabase()
  4.   end if
  5.   updateScrollArea(clickV, scrollSprite)
  6.   updateBrowser(scrollSprite)
  7.   updateStage()
  8.   repeat while the mouseDown
  9.     scrollArea(the mouseV, scrollSprite, scrollField)
  10.   end repeat
  11. end
  12.  
  13. on updateScrollArea clickV, scrollSprite
  14.   set the locV of sprite scrollSprite to clickV
  15. end
  16.  
  17. on updateBrowser scrollSprite
  18.   global BrowserScrollBar, browserTopics, numVisibleTopics, browserTopLine
  19.   set scrollHeight to the height of sprite BrowserScrollBar
  20.   set V to the locV of sprite scrollSprite - the top of sprite BrowserScrollBar
  21.   set browserTopLine to V * the number of lines in browserTopics / scrollHeight
  22.   setFieldText("browser", browserTopLine, numVisibleTopics, browserTopics)
  23. end
  24.  
  25. on scrollText clickedSprite, direction
  26.   global textTopLine, numTextLines, textScroll, numVisibleTextLines, topicText
  27.   scroll(clickedSprite, direction, textTopLine, "Displayed Text", numTextLines, textScroll, numVisibleTextLines, topicText)
  28. end
  29.  
  30. on scrollBrowser clickedSprite, direction
  31.   global browserTopLine, browserScroll, numVisibleTopics, browserTopics
  32.   set numLines to the number of lines in browserTopics
  33.   clearDatabase()
  34.   scroll(clickedSprite, direction, browserTopLine, "browser", numLines, browserScroll, numVisibleTopics, browserTopics)
  35. end
  36.  
  37. on scroll clickedSprite, direction, topline, scrollField, numLines, scrollSprite, numVisibleLines, allText
  38.   set topline to updateTopLine(direction, topline, numLines, scrollField)
  39.   moveScrollSquareToMatchText(topline, scrollSprite)
  40.   setFieldText(scrollField, topline, numVisibleLines, allText)
  41.   set spritecast to the castNum of sprite clickedSprite
  42.   repeat while the mouseDown
  43.     if the mouseCast = spritecast then
  44.       scroll(clickedSprite, direction, topline, scrollField, numLines, scrollSprite, numVisibleLines, allText)
  45.     end if
  46.   end repeat
  47. end
  48.  
  49. on updateTopLine amount, topline, max, scrollField
  50.   set newTopLine to validNum(topline + amount, 1, max)
  51.   updateGlobalTopLine(scrollField, newTopLine)
  52.   return newTopLine
  53. end
  54.  
  55. on updateGlobalTopLine scrollField, newTopLine
  56.   global browserTopLine, textTopLine
  57.   if scrollField = "browser" then
  58.     set browserTopLine to newTopLine
  59.   else
  60.     set textTopLine to newTopLine
  61.   end if
  62. end
  63.  
  64. on moveScrollSquareToMatchText topline, scrollSprite
  65.   global BrowserScrollBar, browserTopics, browserTopLine
  66.   set scrollHeight to the height of sprite BrowserScrollBar
  67.   set V to (topline * scrollHeight / the number of lines in browserTopics) + the top of sprite BrowserScrollBar
  68.   set the locV of sprite scrollSprite to V
  69.   updateStage()
  70. end
  71.  
  72. on getScrollV topline
  73.   global scrollTopValues
  74.   return value(item 1 of line topline of scrollTopValues)
  75. end
  76.  
  77. on setFieldText scrollField, topline, numVisibleLines, allText
  78.   set the text of cast scrollField to line topline to numVisibleLines + topline - 1 of allText
  79.   put EMPTY into line numVisibleLines + 1 of field scrollField
  80. end
  81.  
  82. on displayKeyLineAtTop
  83.   global numberTopics, browserTopics, browserTopLine, numVisibleTopics, browserScroll
  84.   clearDatabase()
  85.   if charToNum(the key) = 30 then
  86.     scroll(0, -1, browserTopLine, "browser", numberTopics, browserScroll, numVisibleTopics, browserTopics)
  87.   else
  88.     if charToNum(the key) = 31 then
  89.       scroll(0, 1, browserTopLine, "browser", numberTopics, browserScroll, numVisibleTopics, browserTopics)
  90.     else
  91.       repeat with i = 1 to numberTopics
  92.         if convertToLower(the key) <= convertToLower(char 1 of line i of browserTopics) then
  93.           set browserTopLine to i
  94.           setFieldText("browser", browserTopLine, numVisibleTopics, browserTopics)
  95.           moveScrollSquareToMatchText(browserTopLine, browserScroll)
  96.           exit repeat
  97.         end if
  98.       end repeat
  99.     end if
  100.   end if
  101. end
  102.